<template>
	<view>
		<uni-table border stripe emptyText="暂无更多数据">
			<uni-tr>
				<uni-th width="120rpx" align="center">姓名</uni-th>
				<uni-th width="120rpx" align="center">用户名</uni-th>
				<uni-th width="120rpx" align="center">部门</uni-th>
				<uni-th width="120rpx" align="center">权重</uni-th>
				<uni-th width="120rpx" align="center">接单开关</uni-th>
			</uni-tr>
			<uni-tr v-for="(item, index) in tableData" :key="index">
				<uni-td width="120rpx" align="center">{{item.name}}</uni-td>
				<uni-td width="120rpx" align="center">{{item.username}}</uni-td>
				<uni-td width="120rpx" align="center">{{item.organize_name}}</uni-td>
				<uni-td width="120rpx" align="center">{{item.weight}}</uni-td>
				<uni-td width="120rpx" align="center">
					<uv-switch v-model="item.order_switch" @change="asyncChange(item)" :activeValue="1"
						:inactiveValue="0"></uv-switch>
				</uni-td>
			</uni-tr>
		</uni-table>
	</view>
</template>

<script>
	import reqApi from "../../api/api.js";
	export default {
		data() {
			return {
				tableData: []
			}
		},
		onShow() {
			this.getTable();
		},
		methods: {
			getTable() {
				reqApi.sellerList({}).then(res => {
					this.tableData = res.data;
				})
			},
			asyncChange(item) {
				console.log("item", item.order_switch);
				// let order_switch = item.order_switch == 1? 0:1;
				reqApi.orderSwitch({
					id: item.id,
					order_switch: item.order_switch
				}).then(res => {
					console.log("修改成功");
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
</style>
